package com.javalong.affairs.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.javalong.affairs.R;
import com.javalong.affairs.adapter.MainAdapter;
import com.javalong.affairs.manager.IntentManager;
import com.javalong.affairs.ui.TopTitle;
import com.javalong.affairs.ui.TopTitle.OnLeftDrawableClick;
import com.javalong.affairs.ui.TopTitle.OnRightDrawableClick;
import com.javalong.affairs.utils.AppUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;

@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity implements OnItemClickListener {
	@ViewInject(R.id.gv_list)
	private GridView gv_list = null;
	@ViewInject(R.id.ui_toptitle)
	private TopTitle topTitle;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewUtils.inject(this);
		gv_list.setAdapter(new MainAdapter(this));
		gv_list.setOnItemClickListener(this);
		topTitle.setOnLeftDrawableClick(this);
		topTitle.setOnRightDrawableClick(new OnRightDrawableClick() {
			@Override
			public void rightClick() {
				IntentManager.doActivity(MainActivity.this,
						UserInfoActivity.class);
			}
		});
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		switch (arg2) {
		case 3:
			IntentManager.doActivity(this, NotificationActivity.class);
			break;
		case 0:
			IntentManager.doActivity(this, TaskSearchActivity.class);
			break;
		case 5:
			IntentManager.doActivity(this, UserInfoActivity.class);
			break;
		case 6:
			IntentManager.doActivity(this, ScheduleActivity.class);
			break;
		case 7:
			// IntentManager.doActivity(this, TaskListActivity.class);
			break;
		}
	}

	@Override
	public void onBackPressed() {
		oneMoreOut();
	}
}
